import type { ObjectDirective, DirectiveBinding } from "vue";
export default defineNuxtPlugin((nuxtApp) => {
  // 定义 focus 指令
  const focusDirective: ObjectDirective<HTMLElement, any> = {
    mounted(el: HTMLElement, binding: DirectiveBinding) {
      if (binding.value !== false) {
        el.focus();
      }
    },
    updated(el: HTMLElement, binding: DirectiveBinding) {
      if (binding.value !== false) {
        el.focus();
      }
    },
  };

  // 注册全局指令
  nuxtApp.vueApp.directive("focus", focusDirective);
});
